package com.andy.controller;

import com.andy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/loginHome")
    public String loginHome() throws Exception{

        return "login";
    }

    @RequestMapping("/login")
    @ResponseBody
    public String login(HttpSession httpSession,String username, String password) throws Exception{
        userService.login(username,password);

        httpSession.setAttribute("session_username",username);

        return "resume";
    }




}
